package cn.st4rlight.util.report.enums;

import java.util.Set;

import cn.st4rlight.util.enums.EnumUtil;
import cn.st4rlight.util.enums.HasCodeAndDesc;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author st4rlight <st4rlight@163.com>
 * Created on 2025-09-14
 */
@Getter
@AllArgsConstructor
public enum SortOrderType implements HasCodeAndDesc {

    ASC(1, "升序"),
    DESC(2, "降序")
    ;

    private final Integer code;
    private final String desc;

    private static final Set<String> NAME_SET = EnumUtil.buildNameSet(SortOrderType.class);

    public static boolean isValidEnum(String enumName) {
        return NAME_SET.contains(enumName);
    }

    public static SortOrderType of(String enumName) {
        return isValidEnum(enumName) ? SortOrderType.valueOf(enumName) : SortOrderType.DESC;
    }
}
